package com.magic.uschat.util;

import java.io.File;
import java.io.IOException;

import com.amap.api.mapcore.util.ca;
import com.magic.uschat.widget.PreviewSurface;

import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.media.MediaRecorder.AudioSource;
import android.media.MediaRecorder.VideoSource;
import android.util.Log;
import android.view.SurfaceView;

public class VideoRecoderUtil {
	
	private Context context;
	private static VideoRecoderUtil _instance =null;
	private PreviewSurface surfaceView;

	private VideoRecoderUtil(Context contex){
		this.context = context;
	}
	
	
	
	public void setPreView(PreviewSurface sf){
		this.surfaceView = sf;
	}
	public synchronized static VideoRecoderUtil getInstance(Context context){
		if (_instance==null) {
			_instance = new VideoRecoderUtil(context);
		}
		return _instance;
	}
	
	public PreviewSurface obtainSurface(Context c){
		this.surfaceView = new PreviewSurface(c);
		return surfaceView;
	}
	
	public void startPreview(){
		//mediaRecorder.setP
	}
	
	public void stopRecorder(){
		surfaceView.stopRecorder();
	}
	public void startRecorder(RecordTimerCallback callback){
		surfaceView.setCallback(callback);
		surfaceView.startRecorder();
	}
	
	public void swithcCamera(){
		surfaceView.getAnotherCam();
	}
	
	public void switchFlash(){
		surfaceView.switchFlash();
	}
	
	public PreviewSurface getPreview(){
		return surfaceView;
	}
	
	public void releaseMedia(){
		surfaceView.releaseMedia();
	}
	public interface RecordTimerCallback{
		public void onRecording(int time);
		public void onUp(File f);
		public void onRecordFinish(File f);
	}
}
